﻿from datetime import datetime
from os.path import dirname, join, abspath, exists
from os import getcwd, makedirs
from sys import stderr, __stderr__
from objects import persons

__dir__ = getcwd()
path_error = join(__dir__, "pers_del.log")
stderr = open(path_error, 'a')
stderr.write("\n\n--------------------------***-----------------------------\nStart...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n")

list=[]
temp=input("Введите табельный номер (4 знака) :\n")
while temp!='':
	list+=[temp]
	temp=input()

print("Табельные номера будут удалены в таблице sa-serv10//mysql//mob_persons")
p=persons()
result=0
for item in list:
	if len(item)==4:
		increment=p.delete(item)
		if type(increment) == str:
			print(increment)
		else:
			result+=increment
	else:
		print('The tabnom : '+item+' length <> 4')
print(str(result) + ' tabnom(s) has(have) been deleted!')


stderr.write("\nNo errors logged.\n\n\n--------------------------***-----------------------------\nFinish...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n\n\n\n")
stderr.close()
stderr = __stderr__